package com.example.sjc715.main.ui.dashboard

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.alibaba.android.arouter.launcher.ARouter
import com.example.net_library.entity.SimpleTypeEntity

class CinemaAdapter(val data:MutableList<SimpleTypeEntity> = mutableListOf(), val f:Fragment):FragmentStateAdapter(f) {
    override fun getItemCount(): Int  = data.size

    override fun createFragment(position: Int): Fragment =
        ARouter.getInstance().build("/home/cinema").
        withString("channel",data[position].channelid).
        navigation() as Fragment

    fun getTitle(position: Int) = data[position].typename

    operator fun plusAssign(list:List<SimpleTypeEntity>){
        val size = data.size
        data+=list
        notifyItemRangeInserted(size,list.size)
    }
}